// B206
// There're 9 digits 1~9
// each digit can only appear once
// find 3 digits that can form a 3-digit number
// abc:def:ghi=1:2:3

#include <iostream>
#include <vector>

// split x into digits
std::vector<int> getDigits(int x);
// check if digits of number are unique
bool checkDigits(int number, std::vector<int>& digits);
// check if all digits are 1~9, Not 0!
bool checkDigitsNotContainZero(std::vector<int>& digits);

int main()
{
    for (int a = 1; a <= 3; a++) {
        for (int b = 1; b <= 9; b++) {
            for (int c = 1; c <= 9; c++) {
                if (a != b && b != c && c != a) {
                    int x = 100 * a + 10 * b + c;
                    int y = 2 * x;
                    int z = 3 * x;

                    // ignore any greater than 999
                    if(y>999 || z>999) continue;

                    // check if all digits are unique
                    std::vector<int> digits;
                    digits.push_back(a);
                    digits.push_back(b);
                    digits.push_back(c);

                    if(checkDigits(y, digits) == false) continue;
                    if(checkDigits(z, digits) == false) continue;

                    // check if all digits are 1~9, Not 0!
                    if(checkDigitsNotContainZero(digits) == false) continue;

                    std::cout << x << ":" << y << ":" << z << std::endl;
                }
            }
        }
    }

    return 0;
}


// split x into digits
std::vector<int> getDigits(int x)
{
    std::vector<int> digits;
    while (x > 0) {
        int d = x % 10;
        digits.push_back(d);
        x /= 10;
    }
    return digits;
}

// check if digits of number are unique
bool checkDigits(int number, std::vector<int>& digits)
{
    auto digitsNew = getDigits(number);
    for (auto d : digitsNew) {
        if (std::find(digits.begin(), digits.end(), d) != digits.end()) {
            // d is already in digits
            return false;
        }
        else {
            digits.push_back(d);
        }
    }

    return true;
}

bool checkDigitsNotContainZero(std::vector<int>& digits)
{
    if (std::find(digits.begin(), digits.end(), 0) != digits.end()) {
		// 0 is in digits
		return false;
	}
    else {
        	return true;
    }
}